package com.example.tys.baseapplication.Mvp.Presenter;

import com.example.tys.baseapplication.Mvp.Model.IModel;
import com.example.tys.baseapplication.Mvp.View.IView;

import java.lang.ref.WeakReference;

/**
 * Created by tys on 2017/9/30.
 */

public class BasePresenter<V extends IView, M extends IModel> {

    protected WeakReference<V> view;
    protected M model;

    public BasePresenter(V view) {
        this.view = new WeakReference<V>(view);
    }


    public void detach() {
        view.clear();
    }

    public void toast(String context) {
        V v;
        if ((v = view.get()) != null) {
            v.toast(context);
        }
    }

}
